#include"ThreadPool.h"
#include<chrono>


int main()
{
	{
		ThreadPool pool;
		pool.setMode(PoolMode::MODE_FIXED);
		pool.setTaskQueMaxThreshHold(2);
		pool.start(2);
		std::future<int> res1 = pool.submitTask([](int a, int b)->int {std::this_thread::sleep_for(std::chrono::seconds(2)); return a + b; }, 1, 2);
		auto res2 = pool.submitTask([](int a, int b, int c)->int {std::this_thread::sleep_for(std::chrono::seconds(3)) ; return a + b + c; }, 1, 2, 3);
		auto res3 = pool.submitTask([](int a, int b, int c)->int {std::this_thread::sleep_for(std::chrono::seconds(3)); return a * b * c; }, 1, 2, 3);
		auto res4 = pool.submitTask([](int a, int b, int c)->int {std::this_thread::sleep_for(std::chrono::seconds(3)); return a * b * c; }, 1, 2, 3);
		auto res5 = pool.submitTask([](int a, int b, int c)->int {std::this_thread::sleep_for(std::chrono::seconds(3)); return a * b * c; }, 1, 2, 3);
		auto res6 = pool.submitTask([](int a, int b, int c)->int {std::this_thread::sleep_for(std::chrono::seconds(3)); return a * b * c; }, 1, 2, 3);
		auto res7 = pool.submitTask([](int a, int b, int c)->int {std::this_thread::sleep_for(std::chrono::seconds(3)); return a * b * c; }, 1, 2, 3);
		auto res8 = pool.submitTask([](int a, int b, int c)->int {std::this_thread::sleep_for(std::chrono::seconds(3)); return a * b * c; }, 1, 2, 3);

		std::cout << res1.get() << std::endl;
		std::cout << res2.get() << std::endl;
		std::cout << res3.get() << std::endl;
		std::cout << res4.get() << std::endl;
		std::cout << res5.get() << std::endl;
		std::cout << res6.get() << std::endl;
		std::cout << res7.get() << std::endl;
		std::cout << res8.get() << std::endl;
	}
	std::cout << "over!" << std::endl;
	getchar();

	return 0;
}